<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:body>
        <p:dialog header="User Detail" widgetVar="userDialogW" resizable="false" id="userDialog"
                  showEffect="fade" hideEffect="explode" modal="true" >  
            <h:form id="userDialogForm">
                <p:messages id="msgs2"/> 

                <h:panelGrid id="userPanelGrid" columns="3" cellpadding="4" style="margin:0 auto;">                    
                    <c:if test="#{!userBackBean.isNew}">
                        <h:outputLabel for="login" value="Login: *" />
                        <h:outputText id="login" value="#{userBackBean.selectedUser.login}"/>
                        <p:message for="login" id="msglogin" display="icon"/>
                    </c:if>
                    <c:if test="#{userBackBean.isNew}">
                        <h:outputLabel for="login2" value="Login: *" />
                        <p:inputText id="login2" value="#{userBackBean.selectedUser.login}" required="true" label="Login" size="45">
                            <f:validateLength minimum="2" />
                        </p:inputText>
                        <p:message for="login2" id="msglogin2" display="icon"/>
                    </c:if>
                    <h:outputLabel for="names" value="Name: *" />  
                    <p:inputText id="names" value="#{userBackBean.selectedUser.name}" required="true" label="Name" size="30">  
                        <f:validateLength minimum="2" />  
                    </p:inputText>
                    <p:message for="names" id="msgnames" display="icon"/>

                    <h:outputLabel for="password" value="Password: *" />  
                    <p:inputText id="password" value="#{userBackBean.password}" required="true" label="Password" size="30">
                        <f:validateLength minimum="2" />  
                    </p:inputText>
                    <p:message for="password" id="msgpassword" display="icon"/>  

                    <h:outputLabel for="roles" value="Groups: *" />  
                    <p:selectManyCheckbox id="roles" value="#{userBackBean.selectedUser.groupTables}"  layout="pageDirection">  
                        <f:selectItems value="#{userBackBean.groupTables}" var="grouptable" itemLabel="#{grouptable.name}" itemValue="#{grouptable}"/>  
                    </p:selectManyCheckbox> 
                    <p:message for="roles" id="msgroles" display="icon"/>  

                    <p:commandButton value="Save" type="submit" update="userDialogForm" actionListener="#{userBackBean.saveUser}" icon="ui-icon-check" />  
                    <p:commandButton value="Close" 
                                     type="submit" 
                                     onclick="userDialogW.hide();" 
                                     label="Close" 
                                     process="@parent" 
                                     actionListener="#{userBackBean.reset}" 
                                     title="Close" 
                                     update=":form:userTable :userDialogForm" 
                                     icon="ui-icon-close"/>  
                </h:panelGrid>
            </h:form>    
        </p:dialog>
    </h:body>

</html>